/****** Object: View [dbo].[vw_3_4_1]   Script Date: 2014-01-19 21:44:29 ******/
USE [SHMIS];
GO
IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[vw_3_4_1]'))
BEGIN
DROP VIEW [dbo].[vw_3_4_1];
END
GO

SET ANSI_NULLS ON;
GO
SET QUOTED_IDENTIFIER ON;
GO
CREATE VIEW [dbo].[vw_3_4_1]
AS
SELECT id.dat_name AS industry,
          i.dat_name AS industry_detail,
          c.customer_simple_name,
          c.customer_simple_code,
          b.Calculated_Area,
          b.Useful_Area,
          c.industry AS industry_db,
          c.industry_detail AS industry_detail_db
     FROM BI_Customer c,
          (SELECT *
             FROM BI_DataDsc
            WHERE dat_code LIKE '10%') i,
          (SELECT *
             FROM BI_DataDsc
            WHERE dat_code = '1000') id,
          BI_MainBusiness b,
          BI_ContractMain cm
    WHERE     c.Deleted = '0'
          AND c.Verified = '1'
          AND b.Deleted = '0'
          AND b.Verified = '1'
          AND cm.Deleted = '0'
          AND cm.Verified = '1'
          AND c.customer_code = cm.Customer_Code
          AND cm.Contract_Num = b.Contract_Num
          AND c.industry_detail = i.dat_value
          AND c.industry = id.dat_value
          AND isnull(cm.Terminated, '0') <> '1'
GO

